home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / desktop / bmp2bgi.zip / BMP2BGI.C < prev    next >
C/C++ Source or Header  |  1991-05-25  |  5KB  |  103 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "bmp.h"
  4.  
  5. extern int fexist (char *);                     // User supplied routine that
  6.                                                 // returns TRUE if file exists
  7.                                                 // or FALSE if not.  Pass the
  8.                                                 // routine your filename as "char *"   
  9.  
  10. extern int AccessBMP (char *);                  // func to check BMP file 
  11.  
  12.                                                 // func to convert BMP to BGI
  13. extern void ProcessBMP (char *, char far *VidBuf[5]);
  14.  
  15. BITMAPFILEHEADER BMPHeader;
  16. BITMAPINFOHEADER BMPInfo;
  17.  
  18. unsigned _stklen = 10240;                       // I like larger stacks
  19.  
  20. void main (int argc, char *argv[])
  21. {
  22.         int x;
  23.         char far *VidBuf[5];                    // stores image
  24.  
  25.  
  26.         if (argc != 2 || !fexist(argv[1]))      // Yo: tell me what to convert
  27.         {
  28.                 printf("\n\aUseage: BMP2BGI <filename.BMP>\n");
  29.                 if (argc == 2) printf("\n\t Check to make sure %s exists\n", argv[1]);
  30.                 exit(0);
  31.         }
  32.  
  33.         x  = AccessBMP(argv[1]);                // Check out the BMP image to
  34.                                                 // see if it's legitimate   
  35.  
  36. ////////////////////////////////////////////////// Inform user about image's characteristx  
  37.         clrscr();
  38.         printf("\nFILE: %s",argv[1]);
  39.         printf("\n═══════════════════════════════════════════════════");
  40.         printf("\nType of BMP: ");
  41.                        if (BMPInfo.biBitCount == 1) printf("Monochrome");
  42.                        else if (BMPInfo.biBitCount == 4) printf("16-Color");
  43.                        else if (BMPInfo.biBitCount == 8) printf("256-Color");
  44.                        else printf("24-Bit RGB");
  45.         if (BMPInfo.biCompression==0) printf("\nCompression Scheme: NONE");
  46.         else                          printf("\nCompression Scheme: %u",BMPInfo.biCompression);
  47.         printf("\nStructure Size: %u",BMPHeader.bfSize-BMPHeader.bfOffBits);
  48.         printf("\nHoriz. Resolution: %u",BMPInfo.biXPelsPerMeter);
  49.         printf("\nVert. Resolution: %u",BMPInfo.biYPelsPerMeter);
  50.         printf("\nPicture Width: %u",BMPInfo.biWidth);
  51.         printf("\nPicture Height: %u",BMPInfo.biHeight);
  52.         printf("\n# of Bits per pixel: %u",BMPInfo.biBitCount);
  53.         printf("\n# of Bitmap Bytes: %u",BMPInfo.biSizeImage);
  54.         printf("\n# of Color Planes: %u",BMPInfo.biPlanes);
  55.         printf("\n═══════════════════════════════════════════════════");
  56.         printf("\n\nConversion Status:");
  57.  
  58.         switch(x)
  59.         {
  60.                 case BMP_OK:            printf("\n\t A-Ok. Proceeding to Convert.\n\n");
  61.                                         break;
  62.                 case BMP_BadDriver:     printf("\n\tGraphics Driver not found.");
  63.                                         printf("\n\tCheck your Video Card.\n\n");
  64.                                         break;
  65.                 case BMP_TooBig:        printf("\n\tBMP file is okay, but the image");
  66.                                         printf("\n\tis larger than your video card");
  67.                                         printf("\n\tcan display.  The BGI image will");
  68.                                         printf("\n\tbe right-clipped, and you will see which");
  69.                                         printf("\n\tparts will remain intact.\n\n");
  70.                                         break;
  71.                 case BMP_WrongVideo:    printf("\n\tThis verison of BMP2BGI can only");
  72.                                         printf("\n\taccomodate 16-Color BMP's. Support");
  73.                                         printf("\n\tshareware and I\'ll be more motivated");
  74.                                         printf("\n\tto implement Mono- & 256-color BMP");
  75.                                         printf("\n\tconversions.\n\n");
  76.                                         break;
  77.                 case BMP_Compression:   printf("\n\tBMP file was saved in a Compressed");
  78.                                         printf("\n\tformat.  BMP2BGI does not support");
  79.                                         printf("\n\tthis feature as of yet.\n\n");
  80.                                         break;
  81.                 default:                printf("\n\t* INTERNAL ERROR *");
  82.                                         printf("\n\t  **** ABORT ****\n\n");
  83.                                         break;
  84.         }
  85.  
  86.         if (x == BMP_OK || x == BMP_TooBig)
  87.         { 
  88.            printf("\n\n> PRESS ANY KEY WHEN READY...");
  89.            getch();
  90.            ProcessBMP(argv[1],VidBuf);
  91.  
  92.            clrscr();                            // PLEASE DO NOT ERASE THIS!
  93.            printf("\n\nConversion Complete. Saved w/ \'.BGI\' file extension");
  94.            printf("\n═════════════════════════════════════════════════════\n");
  95.            printf("\nBMP2BGI: A shareware program by R.G.Rasulis, Jr.");
  96.            printf("\n         Please support by sending $10 to me:");
  97.            printf("\n         Rich Rasulis, Jr.");
  98.            printf("\n         c/o Dep\'t of Psych.");
  99.            printf("\n         U. of Montana");
  100.            printf("\n         Missoula, MT  59801\n\n");
  101.         }
  102.  
  103. }